﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MicroFractal.iTunesBrowser.Controls;
using System.Collections.ObjectModel;
using MicroFractal.iTunesBrowser.Business;

namespace MicroFractal.iTunesBrowser
{
    /// <summary>
    /// Interaction logic for Window2.xaml
    /// </summary>
    public partial class Window2 : Window
    {
        public Window2()
        {
            InitializeComponent();

            listView1.GroupStyleSelector += new GroupStyleSelector(selector);
            listView1.Loaded += new RoutedEventHandler(listView1_Loaded);
        }

        void listView1_Loaded(object sender, RoutedEventArgs e)
        {
            foreach (CollectionViewGroup it in listView1.Items.Groups)
            {
                if (it.Name is Artist)
                {
                }
                else
                {
                }
            }
            
            //listView1.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("Artist.Name", System.ComponentModel.ListSortDirection.Ascending));
        }

        public GroupStyle selector(CollectionViewGroup g, int i)
        {
            //if (g == null) return null;
            
            //if (g.Name is Artist)
            //{
            //    return listView1.GroupStyle[0];
            //    foreach (GroupStyle gro in listView1.GroupStyle)
            //    {
            //    }
            //}
            //else
            //{
            //    return listView1.GroupStyle[0];
            //}
            return null;
        }
    }

    

    public sealed class CoverList : ObservableCollection<Album>
    {
        public CoverList()
        {
            Artist at = new Artist("Metallica");
            Album a = new Album("Black Album", at);
            a.Songs.Add(new Song("primara cancion"));
            a.Songs[0].Artist = at;
            a.Songs[0].Album = a;
            a.Cover = new BitmapImage(new Uri("C:\\covers\\1.jpg"));

            Add(a);

            at = new Artist("Beatles");
            a = new Album("Un Album con un titulo largo, largo, largo... mucho mas largo que los demas", at);
            a.Songs.Add(new Song("primara cancion"));
            a.Songs[0].Artist = at;
            a.Songs[0].Album = a;
            a.Songs.Add(new Song("segunda cancion con titulo buen largo haaja"));
            a.Songs[1].Artist = at;
            a.Songs[1].Album = a;
            a.Cover = new BitmapImage(new Uri("C:\\covers\\2.jpg"));
            Add(a);

            a = new Album("Saint Peppers");
            a.Songs.Add(new Song("primara cancion"));
            a.Songs[0].Artist = at;
            a.Songs[0].Album = a;
            a.Cover = new BitmapImage(new Uri("C:\\covers\\3.jpg"));
            Add(a);

            a = new Album("Vacio", at);
            a.Songs.Add(new Song("segunda cancion"));
            a.Songs[0].Artist = at;
            a.Songs[0].Album = a;
            Add(a);
        }
    }

    public sealed class SongList : ObservableCollection<Song>
    {
        public SongList()
        {
            foreach (Album a in new CoverList())
	{
                foreach (Song s in a.Songs)
	{
                    Add(s);
	}
	}
        }
    }
}
